/**
 * Project Name:ylbx
 * File Name:BxmidleDataSource.java
 * Package Name:dln.stat.impl
 * Copyright (c) 2014, All Rights Reserved.
 *
 */
package dln.stat.ds;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import dao.hb.BxMidle;

/**
 * ClassName: BxmidleDataSource <br/>
 * Function: 报销通用
 * date: May 24, 2014 11:02:47 AM <br/>
 *
 * @author $dev
 * @version 1.0
 */
public class BxmidleDataSource extends AbstractStatDataSource<BxMidle> {
	
	private static final String HORN = "--";
	private static final String ANONYMOUS = "无名";
	private String nameQuery;
	
	public BxmidleDataSource(String nameQuery) {
		this.nameQuery = nameQuery;
	}

    /**
     * @param list
     * @return
     */
	protected List<BxMidle> listProcesser(List<?> origin) {
		List<BxMidle> blist = new ArrayList<BxMidle>();
		if (origin != null) {
            for (int i = 0; i < origin.size(); i++) {
                BxMidle b = new BxMidle();
                preProcess(origin.get(i), b);
                blist.add(b);
            }
        }
        return blist;
	}
	
	protected void preProcess(Object obj, BxMidle b) {
		if (obj.getClass().isArray()) {
			Object[] o = (Object[]) obj;
            b.setname(o[0] != null ? o[0].toString() : ANONYMOUS);
            b.setBxtype(o[1] != null ? o[1].toString() : "");
            b.setPayone(o[2] != null ? (Double) o[2] : 0.0);
            b.setPaytwo(o[3] != null ? (Double) o[3] : 0.0);
            b.setPayall(o[4] != null ? (Double) o[4] : 0.0);
            b.setBxSum(o[5] != null ? (Double) o[5] : 0.0);
            b.setDtLook((Date) (o[6] != null ? o[6] : HORN));
		}
	}

    /**
     * @return
     */
    protected String getNameQuery() {
        return nameQuery;
    }

}
